package Java9_13;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Work2 {
    public static void main(String[] args) {
        SimpleDateFormat[] sj = {new SimpleDateFormat("yyyy/MM/dd"), new SimpleDateFormat("yyyyMMdd"), new SimpleDateFormat("yyyy-MM-dd")};
        Scanner in = new Scanner(System.in);
        System.out.println("输入日期");
        String s = in.next();
        for (int i = 0; i < 3; i++) {
            try {
                sj[i].setLenient(false);
                System.out.println(sj[i].parse(s));
                return;
            } catch (ParseException e) {
            }
        }
        System.out.println("格式错误");
    }
}
